package com.drafthj.study.spring5.ioc.dependencies.injection.staticFactory;

import com.drafthj.study.spring5.ioc.dependencies.injection.AnotherBean;
import com.drafthj.study.spring5.ioc.dependencies.injection.YetAnotherBean;

/**
 * 〈一句话功能简述〉
 * 〈功能详细描述〉
 *
 * @author drafthj
 * @date 2021/1/28
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class ExampleBean {
    private AnotherBean beanOne;

    private YetAnotherBean beanTwo;

    private int i;

    private ExampleBean() {
    }

    public AnotherBean getBeanOne() {
        return beanOne;
    }

    public YetAnotherBean getBeanTwo() {
        return beanTwo;
    }

    public int getI() {
        return i;
    }

    // a static factory method; the arguments to this method can be
    // considered the dependencies of the bean that is returned,
    // regardless of how those arguments are actually used.
    public static ExampleBean createInstance (
            AnotherBean anotherBean, YetAnotherBean yetAnotherBean, int i) {

        ExampleBean eb = new ExampleBean ();
        eb.beanOne = anotherBean;
        eb.beanTwo = yetAnotherBean;
        eb.i = i;
        // some other operations...
        return eb;
    }
}
